<!DOCTYPE html>
<html ng-app="myApp">
<head>
  <title></title>
  <meta charset="utf-8">
  <script src="../angular-1.3.2.js"></script>
  <script src="angular-sanitize.min.js"></script>
  <script src="script.js"></script>
  <link type="text/css" href="../bootstrap.css" rel="stylesheet" />
</head>
<body>
<div class="container">
  <table class="table table-bordered" ng-controller="ctrl">
    <caption>通过ngSanitize模块的$sanitize服务解析html</caption>
    <thead>
    <tr>
      <th>使用的指令</th>
      <th>格式化方法</th>
      <th>指令的写法</th>
      <th>解析结果</th>
    </tr>
    </thead>
    <tbody>
    <tr>
      <td>ng-bind-html</td>
      <td>使用内置的$sanitize <br/>(不需要出现在js里,只要模型添加了ngSanitize模块, <br/>然后使用ng-bind-html,它的值就自动通过$sanitize编译)</td>
      <td><pre>&lt;div ng-bind-html="myHtml"&gt;<br>&lt;/div&gt;</pre></td>
      <td><div ng-bind-html="myHtml"></div></td>
    </tr>
    <tr>
      <td>ng-bind-html</td>
      <td>使用$sce的trustAsHtml方法编译<br/>(以后会细讲$sce服务,这里不是重点)</td>
      <td><pre>&lt;div ng-bind-html="trustHtml"&gt;<br>&lt;/div&gt;</pre></td>
      <td><div ng-bind-html="trustHtml"></div></td>
    </tr>
    <tr>
      <td>ng-bind</td>
      <td>不编译</td>
      <td><pre>&lt;div ng-bind="myHtml"&gt;<br>&lt;/div&gt;</pre></td>
      <td><div ng-bind="myHtml"></div></td>
    </tr>
    </tbody>
  </table>
  <a class="btn btn-default" href="http://plnkr.co/edit/3FBasliZTRjKs3jwTpoR?p=preview" role="button">plunker</a>
  <table class="table table-bordered" ng-controller="ctrlLinky">
    <caption>通过ngSanitize模块的linky过滤器编译链接</caption>
    <thead>
    <tr>
      <th>过滤方式</th>
      <th>指令的写法</th>
      <th>解析结果</th>
    </tr>
    </thead>
    <tbody>
    <tr>
      <td>使用linky编译链接</td>
      <td><pre>&lt;div ng-bind-html="myHtml | linky"&gt;<br>&lt;/div&gt;</pre></td>
      <td><div ng-bind-html="myHtml | linky"></div></td>
    </tr>
    <tr>
      <td>使用linky+target编译链接</td>
      <td><pre>&lt;div ng-bind-html="myHtml | linky:'_blank'"&gt;<br>&lt;/div&gt;</pre></td>
      <td><div ng-bind-html="myHtml | linky:'_blank'"></div></td>
    </tr>
    <tr>
      <td>不编译链接</td>
      <td><pre>&lt;div ng-bind-html="myHtml"&gt;<br>&lt;/div&gt;</pre></td>
      <td><div ng-bind-html="myHtml"></div></td>
    </tr>
    </tbody>
  </table>
  <a class="btn btn-default" href="http://plnkr.co/edit/I9j13MnyuDwOJPnBiKE1?p=preview" role="button">plunker</a>

</div>
</body>
</html>


